﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartRS.com.vn.smartrs.domain.custom
{
    public class BillReportDataRow
    {
        public long billId { get; set;}
        public long stt { get; set; }
        public string billSerial { get; set;}
        public string deskInfo {get; set;}
        public string customer {get; set;}
        public string userOutput {get; set;}
        public DateTime outputDate {get; set;}
        public long discountValue {get; set;}
        public long cashCharge { get; set; }

        public BillReportDataRow copyProperties(Bill bill)
        {
            try
            {
                if (bill == null)
                {
                    return new BillReportDataRow();
                }
                BillReportDataRow billResult = new BillReportDataRow()
                {
                    billId = bill.billId,
                    billSerial = bill.billSerial,
                    deskInfo = bill.desk.hall.hallName + " - " + bill.desk.deskName,
                    customer = "----",
                    userOutput = null != bill.account ? bill.account.fullName : "unknow",//"unknow => load null",//bill.account.username,
                    outputDate = bill.outputDate,
                    discountValue = bill.discountValue,
                    cashCharge = bill.cashCharge
                };

                return billResult;
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        public IList<BillReportDataRow> copyProperties(IList<Bill> listBill)
        {
            try
            {
                IList<BillReportDataRow> listResult = new List<BillReportDataRow>();
                if (listBill == null || listBill.Count <= 0)
                {
                    return listResult;
                }
                long stt = 0;
                foreach (Bill bill in listBill)
                {
                    BillReportDataRow tmpBillReport = copyProperties(bill);
                    tmpBillReport.stt = ++stt;
                    listResult.Add(tmpBillReport);
                }

                return listResult;
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }
    }
}
